package cn.wolfcode.wolf2w.common.sms.config;

import cn.wolfcode.wolf2w.common.sms.service.impl.TencentSmsServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
//当classpath 中配置文件配置了： tencent.sms.templateId key， 然后再加载下面的@Bean到容器
@ConditionalOnProperty(prefix = "tencent.sms",name="templateId")
public class SmsAutoConfiguration {

    @Bean
    //从配置文件中获取以tencent.sms配置属性， 绑定到下面的属性中
    @ConfigurationProperties(prefix = "tencent.sms")
    public SmsProperties smsProperties(){
        return new SmsProperties();
    }

    @Bean
    public TencentSmsServiceImpl tencentSmsService(){
        return new TencentSmsServiceImpl();
    }
}
